import React, { useRef, useEffect, forwardRef } from 'react'
import { useGLTF, useAnimations } from '@react-three/drei'

const BeltConveyor = forwardRef((props, ref) => {
  const { nodes, materials, animations } = useGLTF('/models/beltConveyor.glb')
  const groupRef = useRef()
  const { actions } = useAnimations(animations, groupRef)
  useEffect(() => {
    for (const k in actions) {
      actions[k].play()
    }
  }, [actions]);
  return (
    <group visible={false} ref={ref} scale={0.001} dispose={null} >
      <group scale={0.6} position={[3.4, 0, 0]}>
        <mesh geometry={nodes.立方体.geometry} material={materials.材质} position={[0, 0.929651, 0]} />
        <mesh geometry={nodes.柱体027.geometry} material={materials['材质.001']} position={[5.063495, -0.044317, -1.635729]} rotation={[0, 0, -Math.PI / 2]} scale={[0.309738, 0.635395, 0.309738]} />
        <mesh geometry={nodes.平面.geometry} material={materials['Material.007']} position={[-13.51551, 0.26626, 0.005532]} scale={[0.34994, 1, 0.757135]} />
        <instancedMesh args={[nodes.meitan001.geometry, materials['Material.007'], 8]} instanceMatrix={nodes.meitan001.instanceMatrix} />
      </group>
    </group>
  )
})

useGLTF.preload('/models/beltConveyor.glb')

export default BeltConveyor;
